class TreeNode:
    def __init__(self, val=0, left=None, right=None):
        self.val = val
        self.left = left
        self.right = right

def inorderTraversal(root: TreeNode):
    def inorder(node, res):
        if not node:
            return
        inorder(node.left, res)  # 遍历左子树
        print("val=", node.val)
        res.append(node.val)     # 访问根节点
        inorder(node.right, res) # 遍历右子树
    
    result = []
    inorder(root, result)
    return result

def test_inorderTraversal():
    # 测试示例 1
    root = TreeNode(1)
    root.right = TreeNode(2)
    root.right.left = TreeNode(3)
    assert inorderTraversal(root) == [1, 3, 2], "测试示例 1 失败"
    
    # 测试示例 2: 空树
    root = None
    assert inorderTraversal(root) == [], "测试示例 2 失败"
    
    # 测试示例 3: 只有一个节点的树
    root = TreeNode(1)
    assert inorderTraversal(root) == [1], "测试示例 3 失败"
    
    # 测试示例 4: 完全二叉树
    root = TreeNode(1)
    root.left = TreeNode(2)
    root.right = TreeNode(3)
    root.left.left = TreeNode(4)
    root.left.right = TreeNode(5)
    root.right.left = TreeNode(6)
    root.right.right = TreeNode(7)
    assert inorderTraversal(root) == [4, 2, 5, 1, 6, 3, 7], "测试示例 4 失败"
    
    print("所有测试用例通过！")

# 运行测试
test_inorderTraversal()